#ifndef LAURIN_DISCOVER_NETWORK_CLIENTS_MODULE_H_
#define LAURIN_DISCOVER_NETWORK_CLIENTS_MODULE_H_

#include "laurin-module.h"
#include "laurin-module-handler.h"
#include "laurin-network-device.h"
#include "network/laurin-ip-network.h"
#include <glibmm/ustring.h>


/**
 * External handler for processPacket()
 */
void processPacketExtForClients(u_char* arg, const struct pcap_pkthdr *header,const u_char *data);



/**
 * This module scan the the ip network for discovering connected clients.
 *
 * It generates an ARP request for each possible client on the net. Those who responds are considered avaible.
 * ARP was preferred to ping for efficiency and reliability reasons.
 *
 * The module is governed by the packet timeout response.
 */
class LaurinDiscoverNetworkClientsModule : public LaurinModule
{

	friend void processPacketExtForClients(u_char* arg, const struct pcap_pkthdr *header,const u_char *data);

	public:

		LaurinDiscoverNetworkClientsModule(const Glib::ustring& ifaceName, LaurinModuleHandler* handler);
		virtual ~LaurinDiscoverNetworkClientsModule();

		bool isInitialized() const;
		void setPacketTimeout(int second);
		int getPacketTimeout() const;


		LaurinIPNetwork* getIPNetwork() const;

	protected:

		virtual bool run();
		virtual void innerStop();


	private:

		void processPacket(const struct pcap_pkthdr *header,const u_char *data);

		LaurinNetworkDevice* _device;
		int _timeout;


};

#endif
